﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LumenWorks.Framework.IO.Csv;
using System.IO; 
using LumenWorks.Framework.Tests.Unit.IO.Csv;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Adex; 
using System.Transactions;
using System.Drawing;
using MediaMonitor.Common;
using Telerik.Web.UI;
using System.Web.UI.HtmlControls;

namespace MediaMonitor.Admin
{
    public partial class PeopleLink : Adex.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
      
        protected void radGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {

            DataTable dt = new DataTable();
            dt = SPs.OtherPeopleNameAdminSectionPeopleLink().GetDataSet().Tables[0];
            radGrid.DataSource = dt;
            //radGrid.DataBind();

        }
        protected void radGrid_ItemCommand(object source, GridCommandEventArgs e)
        {

           
            if (e.CommandName == "Change")
            {
                GridDataItem item = (GridDataItem)e.Item;
                RadGrid gridComment = (RadGrid)item.FindControl("radGridComment");
                hdnName.Value = ((Label)e.Item.FindControl("lblName")).Text;
                hdnID.Value = e.CommandArgument.ToString();
                pnlUpload.Visible = true;
            }
        }
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            string errMsg1=string.Empty;
           
            if (flRF1.HasFile)
            {
                try
                    
                {
                   
                    string filename = Path.GetFileName(flRF1.FileName);
                    filename = hdnName.Value.ToString().Replace("/", "_").Replace(" ", "") + ".pdf";
                    flRF1.SaveAs(Server.MapPath("../File_People_link/") + filename);
                    SPs.AddupdateOtherPeopleName("", "", Convert.ToInt32(hdnID.Value),0).Execute();
                    
                    errMsg1 = "<h2>File Uploaded Successfully</h2>";
                }
                catch (Exception ex)
                {
                    errMsg1 = "<h2>File Not Uploaded</h2>";
                }
               
            }
            DataTable dt = new DataTable();
            dt = SPs.OtherPeopleNameAdminSectionPeopleLink().GetDataSet().Tables[0];
            radGrid.DataSource = dt;
            radGrid.DataBind();
        }
       

    }
}
